﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;


namespace PRJ1109.Pages
{
    /// <summary>
    /// WaitPage.xaml 的交互逻辑
    /// </summary>
    public partial class WaitPage : Page
    {
        DispatcherTimer? _timer = new DispatcherTimer();
        public WaitPage()
        {
            InitializeComponent();
            
            _timer.Interval = TimeSpan.FromMicroseconds(200);
            _timer.Tick += _timer_Tick;
            _timer.Start();
            Unloaded += Page_Unloaded;
        }
        private void _timer_Tick(object sender, EventArgs e)
        {
            timeText.Text = DateTime.Now.ToShortTimeString();
        }
        private void Page_Unloaded(object sender, RoutedEventArgs e)
        {
            if(_timer != null)
            {   
                _timer.Stop();
                _timer = null; // 允许计时器对象被垃圾回收
            }
            
            
        }

    }
}
